!>\file set_soilveg_ruc.F90
!! This file contains subroutine to specify vegetation and soil
!! parameters for a given soild and land-use classification. 

      module set_soilveg_ruc_mod

      use namelist_soilveg_ruc

      implicit none

      private

      public :: set_soilveg_ruc

      contains

!>\ingroup lsm_ruc_group
!! This subroutine specifies vegetation and soil parameters for a given
!! soil and land-use classification.
      subroutine set_soilveg_ruc(me,isot,ivet,nlunit)

      integer, intent(in) :: isot,ivet,nlunit
      integer me

      integer i
      real refsmc1, wltsmc1

      NAMELIST /SOIL_VEG_RUC/ SLOPE_DATA, ALBTBL, Z0TBL, LEMITBL,       &
     &  PCTBL, SHDTBL,                                                  &
     &  IFORTBL, RSTBL, RGLTBL, HSTBL, SNUPTBL, LAITBL, MAXALB,         &
     &  LPARAM, TOPT_DATA, CMCMAX_DATA, CFACTR_DATA,                    &
     &  RSMAX_DATA, BARE, NATURAL, CROP, URBAN,                         &
     &  DEFINED_VEG, DEFINED_SOIL, DEFINED_SLOPE,                       &
     &  BB, DRYSMC, HC, MAXSMC, REFSMC, SATPSI, SATDK, SATDW,           &
     &  WLTSMC, QTZ, mosaic_soil, mosaic_lu,                            &
     &  REFSMCnoah, WLTSMCnoah, MAXSMCnoah

      if(ivet.eq.2) then
! Using umd veg classification
      slope_data =(/0.1,  0.6, 1.0, 0.35, 0.55, 0.8,            &
     &  	       0.63, 0.0, 0.0, 0.0,  0.0,  0.0,         &
     &  	       0.0 , 0.0, 0.0, 0.0,  0.0,  0.0,         &
     &  	       0.0 , 0.0, 0.0, 0.0,  0.0,  0.0,         & 
     &  	       0.0 , 0.0, 0.0, 0.0,  0.0,  0.0/)
! ----------------------------------------------------------------------
! vegetation class-related arrays
! ----------------------------------------------------------------------
      rstbl      =(/300.0, 175.0, 175.0, 300.0, 300.0, 70.0,    &
     &              20.0, 225.0, 225.0, 225.0, 400.0, 20.0,     &
     &  	   150.0,   0.0,   0.0,   0.0,   0.0,  0.0,     &
     &  	     0.0,   0.0,   0.0,   0.0,   0.0,  0.0,     &
     &  	     0.0,   0.0,   0.0,   0.0,   0.0,  0.0/)

      rgltbl     =(/30.0,  30.0,  30.0,  30.0,  30.0,  65.0,    &
     &  	  100.0, 100.0, 100.0, 100.0, 100.0, 100.0,     &
     &  	  100.0,   0.0,   0.0,   0.0,	0.0,   0.0,     &
     &  	    0.0,   0.0,   0.0,   0.0,	0.0,   0.0,     &
     &  	    0.0,   0.0,   0.0,   0.0,	0.0,   0.0/)

      hstbl      =(/41.69, 54.53, 51.93, 47.35,  47.35, 54.53,  &
     &  	  36.35, 42.00, 42.00, 42.00,  42.00, 36.35,    &
     &  	  42.00,  0.00,  0.00,  0.00,	0.00,  0.00,    &
     &  	   0.00,  0.00,  0.00,  0.00,	0.00,  0.00,    &
     &  	   0.00,  0.00,  0.00,  0.00,	0.00,  0.00/)

      snuptbl   =(/0.040, 0.040, 0.040, 0.040, 0.040, 0.040,    &
     &             0.020, 0.020, 0.020, 0.020, 0.013, 0.020,    &
     &             0.013, 0.000, 0.000, 0.000, 0.000, 0.000,    &
     &  	   0.000, 0.000, 0.000, 0.000, 0.000, 0.000,    &
     &  	   0.000, 0.000, 0.000, 0.000, 0.000, 0.000/)
 
      bare =11

!---------------------------------------------------------------------
! number of defined veg used.
! ----------------------------------------------------------------------
      defined_veg=13
      defined_slope = 9
      z0tbl      =(/2.653, 0.826, 0.563, 1.089, 0.854, 0.856,   &
     &              0.035, 0.238, 0.065, 0.076, 0.011, 0.125,   &
     &              0.011, 0.000, 0.000, 0.000, 0.000, 0.000,   &
     &              0.000, 0.000, 0.000, 0.000, 0.000, 0.000,   &
     &              0.000, 0.000, 0.000, 0.000, 0.000, 0.000/)
      laitbl      =(/3.0, 3.0, 3.0, 3.0, 3.0, 3.0,              &
     &               3.0, 3.0, 3.0, 3.0, 3.0, 3.0,              &
     &               3.0, 0.0, 0.0, 0.0, 0.0, 0.0,              &
     &               0.0, 0.0, 0.0, 0.0, 0.0, 0.0,              &
     &               0.0, 0.0, 0.0, 0.0, 0.0, 0.0/)

! Using igbp ivegetation classification - MODI-RUC
      elseif(ivet.eq.1)then
!--------------------------------------------------------------------------------------------------------------------------------------
!21,1, 'ALBEDO    Z0    LEMI    PC   SHDFAC IFOR    RS       RGL    HS     SNUP    LAI    MAXALB'
!1       .12,    .80,   .950,  .55,    .70,   1,    125.,    30., 47.35,   0.08,   6.40,   52.,     'Evergreen Needleleaf Forest'
!2,      .12,    .80,   .950,  .55,    .95,   2,    150.,    30., 41.69,   0.08,   6.48,   35.,     'Evergreen Broadleaf Forest'
!3,      .14,    .80,   .940,  .55,    .70,   4,    150.,    30., 47.35,   0.08,   5.16,   54.,     'Deciduous Needleleaf Forest'
!4,      .16,    .80,   .930,  .55,    .80,   3,    100.,    30., 54.53,   0.08,   3.31,   58.,     'Deciduous Broadleaf Forest'
!5,      .13,    .80,   .940,  .55,    .80,   2,    125.,    30., 51.93,   0.08,   5.50,   53.,     'Mixed Forests'
!6,      .22,    .10,   .930,  .40,    .70,   4,    300.,   100., 42.00,   0.03,   3.66,   60.,     'Closed Shrublands'
!7,      .20,    .10,   .880,  .40,    .70,   4,    170.,   100., 39.18,  0.035,   2.60,   65.,     'Open Shrublands'
!8,      .20,    .30,   .930,  .40,    .70,   5,    300.,   100., 42.00,   0.03,   3.66,   60.,     'Woody Savannas'
!9,      .20,    .15,   .920,  .40,    .50,   5,     70.,    65., 54.53,   0.04,   3.66,   50.,     'Savannas'
!10,     .19,   .075,   .920,  .40,    .80,   5,     40.,   100., 36.35,   0.04,   2.90,   70.,     'Grasslands'
!11      .14,    .30,   .950,  .40,    .60,   4,     70.,    65.,   55.97 0.015    5.72,   59.,     'Permanent wetlands'
!12,     .18,    .20,   .935,  .40,    .80,   7,     40.,   100., 36.25,   0.04,   5.68,   66.,     'Croplands'
!13,     .18,    0.5,   .880,  .40,    .10,   9,    200.,   999., 999.0,   0.04,   1.00,   46.,     'Urban and Built-Up'
!14      .16,    .30,   .920,  .40,    .80,   7,     40.,   100., 36.25,   0.04,   4.29,   68.,     'cropland/natural vegetation mosaic'
!15,     .55,   .011,   .980,  .00,    .00,   9,    999.,   999., 999.0,   0.02,   0.01,   82.,     'Snow and Ice'
!16,     .25,   .065,   .850,  .30,    .01,   5,    999.,   999., 999.0,   0.02,   0.75,   75.,     'Barren or Sparsely Vegetated'
!17,     .08,  .0001,   .980,  .00,    .00,   9,    100.,    30., 51.75,   0.01,   0.01,   70.,     'Water'
!18,     .15,    .15,   .930,  .40,    .60,   5,    150.,   100., 42.00,  0.025,   3.35,   55.,     'Wooded Tundra'
!19,     .15,   .075,   .920,  .40,    .60,   5,    150.,   100., 42.00,  0.025,   3.35,   60.,     'Mixed Tundra'
!20,     .15,    .06,   .900,  .30,    .30,   5,    200.,   100., 42.00,   0.02,   3.35,   75.,     'Barren Tundra'
!21,     .08,  .0001,   .980,  .00,    .00,   9,    100.,    30., 51.75,   0.01,   0.01,   70.,     'Lakes'
!--------------------------------------------------------------------------------------------------------------------------------------

! number of defined veg used.
      defined_veg=21
      defined_slope=20

      SLOPE_DATA    =(/1.0, 1.0, 1.0, 1.0, 1.0, 1.0,            &
     &                 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,            &
     &                 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,            &
     &                 1.0, 1.0, 0.0, 0.0, 0.0, 0.0,            &
     &                 0.0, 0.0, 0.0, 0.0, 0.0, 0.0/)
! ----------------------------------------------------------------------
! VEGETATION CLASS-RELATED ARRAYS
! ----------------------------------------------------------------------
      RStbl     = (/125.0, 150.0, 150.0, 100.0, 125.0, 300.0,   &
     &              170.0, 300.0,  70.0,  40.0,  70.0,  40.0,   &
     &              200.0,  40.0, 999.0, 999.0, 100.0, 150.0,   &
     &              150.0, 200.0, 100.0,   0.0,   0.0,  0.0,    &
     &                0.0,   0.0,   0.0,   0.0,   0.0,  0.0/)
 
      RGLtbl    = (/30.0,  30.0,  30.0,  30.0,  30.0, 100.0,    &
     &             100.0, 100.0,  65.0, 100.0,  65.0, 100.0,    &
     &             999.0, 100.0, 999.0, 999.0,  30.0, 100.0,    &
     &             100.0, 100.0,  30.0,   0.0,   0.0,   0.0,    &
     &               0.0,   0.0,   0.0,   0.0,   0.0,   0.0/)

      HStbl     = (/47.35, 41.69, 47.35, 54.53, 51.93, 42.00,   &
     &              39.18, 42.00, 54.53, 36.35, 55.97, 36.25,   &
     &             999.00, 36.25,999.00,999.00, 51.75, 42.00,   &
     &              42.00, 42.00, 51.75,  0.00,  0.00,  0.00,   &
     &               0.00,  0.00,  0.00,  0.00,  0.00,  0.00/)

      SNUPtbl   =(/0.080, 0.080, 0.080, 0.080, 0.080, 0.030,    &
     &             0.035, 0.030, 0.040, 0.040, 0.015, 0.040,    &
     &             0.040, 0.040, 0.020, 0.020, 0.010, 0.025,    &
     &             0.025, 0.020, 0.010, 0.000, 0.000, 0.000,    &
     &             0.000, 0.000, 0.000, 0.000, 0.000, 0.000/)

      albtbl     =(/0.12, 0.12, 0.14, 0.16, 0.13, 0.22, 0.20,   &
     &              0.20, 0.20, 0.19, 0.14, 0.18, 0.18, 0.16,   &
     &              0.55, 0.25, 0.08, 0.15, 0.15, 0.15, 0.08,   &
     &              0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,   &
     &              0.00, 0.00/)

      Z0tbl      =(/0.80,  0.80,  0.80,  0.80,  0.80,  0.10,    &
     &              0.10,  0.30,  0.15,  0.075, 0.30,  0.20,    &
     &              0.50,  0.30,  0.011, 0.065, 0.0001,0.15,    &
     &              0.075, 0.06,  0.0001,0.000, 0.000, 0.000,   &
     &              0.000, 0.000, 0.000, 0.000, 0.000, 0.000/) 

      lemitbl    =(/.950, .950, .940, .930, .940, .930, .880,   &
     &              .930, .920, .920, .950, .935, .880, .920,   &
     &              .980, .850, .980, .930, .920, .900, .980,   &
     &              0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,   &
     &              0.00, 0.00/)

      pctbl      =(/0.55, 0.55, 0.55, 0.55, 0.55, 0.40, 0.40,   &
     &              0.40, 0.40, 0.40, 0.40, 0.40, 0.40, 0.40,   &
     &              0.00, 0.30, 0.00, 0.40, 0.40, 0.30, 0.00,   &
     &              0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,   &
     &              0.00, 0.00/)

      shdtbl      =(/0.70, 0.95, 0.70, 0.80, 0.80, 0.70, 0.70,  &
     &               0.70, 0.50, 0.80, 0.60, 0.80, 0.10, 0.80,  &
     &               0.00, 0.01, 0.00, 0.60, 0.60, 0.30, 0.00,  &
     &               0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,  &
     &               0.00, 0.00/)

      ifortbl     =(/1, 2, 4, 3, 2, 4, 4, 5, 5, 5, 4, 7, 9, 7,  &
     &               9, 9, 9, 5, 5, 5, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0/)

      laitbl      =(/6.40, 6.48, 5.16, 3.31, 5.50, 3.66, 2.60,  &
     &               3.66, 3.66, 2.90, 5.72, 5.68, 1.00, 4.29,  &
     &               0.01, 0.75, 0.01, 3.35, 3.35, 3.35, 0.01,  &
     &               0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,  &
     &               0.00, 0.00/)

       maxalb     =(/52., 35., 54., 58., 53., 60., 65., 60.,    &
     &               50., 70., 59., 66., 46., 68., 82., 75.,    &
     &               70., 55., 60., 75., 70.,  0.,  0.,  0.,    &
     &                0.,  0.,  0.,  0.,  0.,  0./) 

      natural = 10
      bare = 16
      crop = 12
      urban = 13
      endif
!  end if veg table

! - set mosaic_lu=1 when info for fractional landuse is available
      mosaic_lu = 0

      topt_data =298.0
      cmcmax_data =0.2e-3
      cfactr_data =0.5
      rsmax_data =5000.0

      if(isot.eq.0) then

! ----------------------------------------------------------------------
! soil texture-related arrays.
! ----------------------------------------------------------------------
      bb         =(/4.26,  8.72, 11.55, 4.74, 10.73,  8.17,       &
     &            6.77,  5.25,  4.26, 0.00,  0.00,  0.00,         &
     &            0.00,  0.00,  0.00, 0.00,  0.00,  0.00,         &
     &            0.00,  0.00,  0.00, 0.00,  0.00,  0.00,         &
     &            0.00,  0.00,  0.00, 0.00,  0.00,  0.00/)

      drysmc   =(/0.029, 0.119, 0.139, 0.047, 0.100, 0.103,       &
     &            0.069, 0.066, 0.029, 0.000, 0.000, 0.000,       &
     &            0.000, 0.000, 0.000, 0.000, 0.000, 0.000,       &
     &            0.000, 0.000, 0.000, 0.000, 0.000, 0.000,       &
     &            0.000, 0.000, 0.000, 0.000, 0.000, 0.000/)

      maxsmc   =(/0.421, 0.464, 0.468, 0.434, 0.406, 0.465,       &
     &            0.404, 0.439, 0.421, 0.000, 0.000, 0.000,       &
     &            0.000, 0.000, 0.000, 0.000, 0.000, 0.000,       &
     &            0.000, 0.000, 0.000, 0.000, 0.000, 0.000,       &
     &            0.000, 0.000, 0.000, 0.000, 0.000, 0.000/)

      refsmc   =(/0.248, 0.368, 0.398, 0.281, 0.321, 0.361,       &
     &            0.293, 0.301, 0.248, 0.000, 0.000, 0.000,       &
     &            0.000, 0.000, 0.000, 0.000, 0.000, 0.000,       &
     &            0.000, 0.000, 0.000, 0.000, 0.000, 0.000,       &
     &            0.000, 0.000, 0.000, 0.000, 0.000, 0.000/)

      satpsi   =(/0.04, 0.62, 0.47, 0.14, 0.10, 0.26,             &
     &            0.14, 0.36, 0.04, 0.00, 0.00, 0.00,             &
     &            0.00, 0.00, 0.00, 0.00, 0.00, 0.00,             &
     &            0.00, 0.00, 0.00, 0.00, 0.00, 0.00,             &
     &            0.00, 0.00, 0.00, 0.00, 0.00, 0.00/)

      satdk    =(/1.41e-5, 0.20e-5, 0.10e-5, 0.52e-5, 0.72e-5,    &
     &            0.25e-5, 0.45e-5, 0.34e-5, 1.41e-5, 0.00,       &
     &            0.00   , 0.00   , 0.00   , 0.00   , 0.00,       &
     &            0.00   , 0.00   , 0.00   , 0.00   , 0.00,       &
     &            0.00   , 0.00   , 0.00   , 0.00   , 0.00,       &
     &            0.00   , 0.00   , 0.00   , 0.00   , 0.00/)

      qtz      =(/0.82, 0.10, 0.25, 0.60, 0.52, 0.35,             &
     &            0.60, 0.40, 0.82, 0.00, 0.00, 0.00,             &
     &            0.00, 0.00, 0.00, 0.00, 0.00, 0.00,             &
     &            0.00, 0.00, 0.00, 0.00, 0.00, 0.00,             &
     &            0.00, 0.00, 0.00, 0.00, 0.00, 0.00/)

      wltsmc   =(/0.029, 0.119, 0.139, 0.047, 0.100, 0.103,       &
     &            0.069, 0.066, 0.029, 0.000, 0.000, 0.000,       &
     &            0.000, 0.000, 0.000, 0.000, 0.000, 0.000,       &
     &            0.000, 0.000, 0.000, 0.000, 0.000, 0.000,       &
     &            0.000, 0.000, 0.000, 0.000, 0.000, 0.000/)

      satdw    =(/5.71e-6, 2.33e-5, 1.16e-5, 7.95e-6, 1.90e-5,    &
     &            1.14e-5, 1.06e-5, 1.46e-5, 5.71e-6, 0.00,       &
     &            0.00   , 0.00   , 0.00   , 0.00   , 0.00,       &
     &            0.00   , 0.00   , 0.00   , 0.00   , 0.00,       &
     &            0.00   , 0.00   , 0.00   , 0.00   , 0.00,       &
     &            0.00   , 0.00   , 0.00   , 0.00   , 0.00/)

! ----------------------------------------------------------------------
! number of defined soiltypes used.
! ----------------------------------------------------------------------

      defined_soil=9

      else

! using STASGO soil classification
!--------------------------------------------------------------------------------------------------------------------------------------
!19,1   'BB      DRYSMC       HC     MAXSMC   REFSMC   SATPSI  SATDK SATDW     WLTSMC  QTZ    '
!1,     4.05,    0.002,      1.47,   0.395,   0.174,   0.121,  1.76E-4, 0.608E-6,   0.033,  0.92, 'SAND'
!2,     4.38,    0.035,      1.41,   0.410,   0.179,   0.090,  1.56E-4, 0.514E-5,   0.055,  0.82, 'LOAMY SAND'
!3,     4.90,    0.041,      1.34,   0.435,   0.249,   0.218,  3.47E-5, 0.805E-5,   0.095,  0.60, 'SANDY LOAM'
!4,     5.30,    0.034,      1.27,   0.485,   0.369,   0.786,  7.20E-6, 0.239E-4,   0.143,  0.25, 'SILT LOAM'
!5,     5.30,    0.034,      1.27,   0.485,   0.369,   0.786,  7.20E-6, 0.239E-4,   0.143,  0.10, 'SILT'
!6,     5.39,    0.050,      1.21,   0.451,   0.314,   0.478,  6.95E-6, 0.143E-4,   0.137,  0.40, 'LOAM'
!7,     7.12,    0.068,      1.18,   0.420,   0.299,   0.299,  6.30E-6, 0.990E-5,   0.148,  0.60, 'SANDY CLAY LOAM'
!8,     7.75,    0.060,      1.32,   0.477,   0.357,   0.356,  1.70E-6, 0.237E-4,   0.208,  0.10, 'SILTY CLAY LOAM'
!9,     8.52,    0.085,      1.23,   0.476,   0.391,   0.630,  2.45E-6, 0.113E-4,   0.230,  0.35, 'CLAY LOAM'
!10,   10.40,    0.100,      1.18,   0.426,   0.316,   0.153,  2.17E-6, 0.187E-4,   0.210,  0.52, 'SANDY CLAY'
!11,   10.40,    0.070,      1.15,   0.492,   0.409,   0.490,  1.03E-6, 0.964E-5,   0.250,  0.10, 'SILTY CLAY'
!12,   11.40,    0.068,      1.09,   0.482,   0.400,   0.405,  1.28E-6, 0.112E-4,   0.268,  0.25, 'CLAY'
!13,    5.39,    0.027,      1.21,   0.451,   0.314,   0.478,  6.95E-6, 0.143E-4,   0.117,  0.05, 'ORGANIC MATERIAL'
!14,     0.0,      0.0,      4.18,   1.0,     1.0,     0.0,      0.0, 0.0,     0.0,    0.00, 'WATER'
!15,    4.05,    0.004,      2.03,   0.200,   0.10 ,   0.121,  1.41E-4, 0.136E-3,   0.006,  0.60, 'BEDROCK'
!16,    4.90,    0.065,      2.10,   0.435,   0.249,   0.218,  3.47E-5, 0.514E-5,   0.114,  0.05, 'OTHER(land-ice)'
!17,   11.40,    0.030,      1.41,   0.468,   0.454,   0.468,  9.74E-7, 0.112E-4,   0.030,  0.60, 'PLAYA'
!18,    4.05,    0.006,      1.41,   0.200,   0.17,    0.069,  1.41E-4, 0.136E-3,   0.006,  0.52, 'LAVA'
!19,    4.05,     0.01,      1.47,   0.339,   0.236,   0.069,  1.76E-4, 0.608E-6,   0.060,  0.92, 'WHITE SAND'
!--------------------------------------------------------------------------------------------------------------------------------------

! number of defined soiltyps used.
      defined_soil=19
! ----------------------------------------------------------------------
! SOIL TEXTURE-RELATED ARRAYS.
! ----------------------------------------------------------------------
      BB       =(/4.05,  4.38,  4.90,  5.30,  5.30,   5.39,       &
     &            7.12,  7.75,  8.52, 10.40, 10.40,  11.40,       &
     &            5.39,  0.00,  4.05,  4.90, 11.40,   4.05,       &
     &            4.05,  0.00,  0.00,  0.00,  0.00,   0.00,       &
     &            0.00,  0.00,  0.00,  0.00,  0.00,   0.00/)

      DRYSMC   =(/0.002, 0.035, 0.041, 0.034, 0.034, 0.050,       &
     &            0.068, 0.060, 0.085, 0.100, 0.070, 0.068,       &
     &            0.027, 0.000, 0.004, 0.065, 0.030, 0.006,       &
     &            0.010, 0.000, 0.000, 0.000, 0.000, 0.000,       &
     &            0.000, 0.000, 0.000, 0.000, 0.000, 0.000/)

      HC       =(/1.47, 1.41, 1.34, 1.27, 1.27, 1.21, 1.18,       &
     &            1.32, 1.23, 1.18, 1.15, 1.09, 1.21, 4.18,       &
     &            2.03, 2.10, 1.41, 1.41, 1.47, 0.00, 0.00,       &
     &            0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,       &
     &            0.00, 0.00/)

      MAXSMC   =(/0.395, 0.410, 0.435, 0.485, 0.485, 0.451,       &
     &            0.420, 0.477, 0.476, 0.426, 0.492, 0.482,       &
     &            0.451, 1.000, 0.200, 0.435, 0.468, 0.200,       &
     &            0.339, 0.000, 0.000, 0.000, 0.000, 0.000,       &
     &            0.000, 0.000, 0.000, 0.000, 0.000, 0.000/)
 
      REFSMC   =(/0.174, 0.179, 0.249, 0.369, 0.369, 0.314,       &
     &            0.299, 0.357, 0.391, 0.316, 0.409, 0.400,       &
     &            0.314, 1.000, 0.100, 0.249, 0.454, 0.170,       &
     &            0.236, 0.000, 0.000, 0.000, 0.000, 0.000,       &
     &            0.000, 0.000, 0.000, 0.000, 0.000, 0.000/)

      SATPSI   =(/0.121, 0.090, 0.218, 0.786, 0.786, 0.478,       &
     &            0.299, 0.356, 0.630, 0.153, 0.490, 0.405,       &
     &            0.478, 0.000, 0.121, 0.218, 0.468, 0.069,       &
     &            0.069, 0.00,  0.00,  0.00,  0.00,  0.00,        &
     &            0.00,  0.00,  0.00,  0.00,  0.00,  0.00/)

      SATDK    =(/1.76e-4, 1.56e-4, 3.47e-5, 7.20e-6, 7.20e-6,    &
     &            6.95e-6, 6.30e-6, 1.70e-6, 2.45e-6, 2.17e-6,    &
     &            1.03e-6, 1.28e-6, 6.95e-6, 0.0,     1.41e-4,    &
     &            3.47e-5, 9.74e-7, 1.41e-4, 1.76e-4, 0.00,       &
     &            0.00   , 0.00   , 0.00   , 0.00   , 0.00,       &
     &            0.00   , 0.00   , 0.00   , 0.00   , 0.00/)

      SATDW    =(/0.608e-6, 0.514e-5, 0.805e-5, 0.239e-4, 0.239e-4,  &
     &            0.143e-4, 0.990e-5, 0.237e-4, 0.113e-4, 0.187e-4,  &
     &            0.964e-5, 0.112e-4, 0.143e-4, 0.0,      0.136e-03, &
     &            0.514e-5, 0.112e-4, 0.136e-3, 0.608e-6, 0.00,      &
     &            0.00   , 0.00   , 0.00   , 0.00   , 0.00,          &
     &            0.00   , 0.00   , 0.00   , 0.00   , 0.00/)

      WLTSMC   =(/0.033, 0.055, 0.095, 0.143, 0.143, 0.137,       &
     &            0.148, 0.208, 0.230, 0.210, 0.250, 0.268,       &
     &            0.117, 0.000, 0.006, 0.114, 0.030, 0.006,       &
     &            0.060, 0.000, 0.000, 0.000, 0.000, 0.000,       &
     &            0.000, 0.000, 0.000, 0.000, 0.000, 0.000/)

      QTZ      =(/0.92, 0.82, 0.60, 0.25, 0.10, 0.40,             &
     &            0.60, 0.10, 0.35, 0.52, 0.10, 0.25,             &
     &            0.05, 0.00, 0.60, 0.05, 0.60, 0.52,             &
     &            0.92, 0.00, 0.00, 0.00, 0.00, 0.00,             &
     &            0.00, 0.00, 0.00, 0.00, 0.00, 0.00/)

! Noah parameter to compute SMCREFnoah and SMCWLTnoah
      BBnoah    =(/4.05,  4.26, 4.74, 5.33, 5.33,  5.25,         &
     &            6.77,  8.72,  8.17, 10.73, 10.39,  11.55,      &
     &            5.25,  4.26,  4.05, 4.26,  11.55,  4.05,       &
     &            4.05,  0.00,  0.00, 0.00,  0.00,  0.00,        &
     &            0.00,  0.00,  0.00, 0.00,  0.00,  0.00/)
      MAXSMCnoah=(/0.395, 0.421, 0.434, 0.476, 0.476, 0.439,     &
     &            0.404, 0.464, 0.465, 0.406, 0.468, 0.457,      &
     &            0.464, 0.421, 0.200, 0.421, 0.457, 0.200,      &
     &            0.395, 0.000, 0.000, 0.000, 0.000, 0.000,      &
     &            0.000, 0.000, 0.000, 0.000, 0.000, 0.000/)   
!
      SATPSInoah=(/0.035, 0.0363, 0.1413, 0.7586, 0.7586, 0.3548, &
     &            0.1349, 0.6166, 0.2630, 0.0977, 0.3236, 0.4677, &
     &            0.3548, 0.0363, 0.0350, 0.0363, 0.4677, 0.0350, &
     &            0.0350, 0.00, 0.00, 0.00, 0.00, 0.00,           &
     &            0.00, 0.00, 0.00, 0.00, 0.00, 0.00/)
      SATDKnoah =(/1.76e-4, 1.4078e-5, 5.2304e-6, 2.8089e-6, 2.8089e-6,&
     &            3.377e-6, 4.4518e-6, 2.0348e-6, 2.4464e-6, 7.2199e-6,&
     &           1.3444e-6, 9.7394e-7, 3.377e-6, 1.4078e-5, 1.4087e-05,&
     &           1.4078e-5, 9.7394e-7, 1.4078e-5, 1.760e-4, 0.00,      &
     &            0.00   , 0.00   , 0.00   , 0.00   , 0.00,            &
     &            0.00   , 0.00   , 0.00   , 0.00   , 0.00/)

      endif
!   end if soil table

         DO I = 1,DEFINED_SOIL
           if (satdknoah(i) /= 0.0 .and. bbnoah(i) > 0.0) then
           REFSMC1   = MAXSMCnoah(I)*(5.79E-9/SATDKnoah(I))  &
     &                  **(1.0/(2.0*BBnoah(I)+3.0))
           REFSMCnoah(I) = REFSMC1 + (MAXSMCnoah(I)-REFSMC1) / 6.
           WLTSMC1   = MAXSMCnoah(I) * (200.0/SATPSInoah(I))**(-1.0/BBnoah(I))
           WLTSMCnoah(I) = WLTSMC1 - 0.5 * WLTSMC1
           endif
         END DO

! - set mosaic_soil=1 when info for fractional landuse is available
      mosaic_soil = 0

! PT 5/18/2015 - changed to FALSE to match atm_namelist setting
! PT LPARAM is not used anywhere
      LPARAM =.FALSE.

         IF (DEFINED_SOIL .GT. MAX_SOILTYP) THEN
            WRITE(0,*) 'Warning: DEFINED_SOIL too large in namelist'
            STOP 222
         ENDIF
         IF (DEFINED_VEG .GT. MAX_VEGTYP) THEN
            WRITE(0,*) 'Warning: DEFINED_VEG too large in namelist'
            STOP 222
         ENDIF
         IF (DEFINED_SLOPE .GT. MAX_SLOPETYP) THEN
            WRITE(0,*) 'Warning: DEFINED_SLOPE too large in namelist'
            STOP 222
         ENDIF
         
!       if (me == 0) write(6,soil_veg_ruc)
       return
       end subroutine set_soilveg_ruc
       end module set_soilveg_ruc_mod
